package CarManagement;

/**
 * @author Davey chan
 */

import java.awt.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class View extends JFrame {

    public static JPanel contentPane;
    public static JTextArea textArea = new JTextArea();
    public static JScrollPane ta = new JScrollPane(textArea);
    /**
     * 展示页面
     */
//    运行入口
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    View frame = new View();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 创建GUI页面
     */
    public View() {
//        标题
        super("车辆管理系统");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setBounds(300, 200, 800, 600);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 10, 10));
        setContentPane(contentPane);

        contentPane.setLayout(null);

        JButton btnNewButton = new JButton("显示车辆信息");
        btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Service.displayall();
            }
        });
        btnNewButton.setBounds(50, 450, 110, 67);
        contentPane.add(btnNewButton);

        JLabel lblNewLabel = new JLabel("车辆管理系统");
        lblNewLabel.setBackground(new Color(12, 252, 60));
        lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
        lblNewLabel.setForeground(Color.RED);
        lblNewLabel.setFont(new Font("楷体", Font.BOLD, 31));
        lblNewLabel.setEnabled(false);
        lblNewLabel.setBounds(212, 10, 245, 100);
        contentPane.add(lblNewLabel);

        JButton btnNewButton_1 = new JButton("添加车辆 ");
        btnNewButton_1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Service.addcar();
            }
        });
        btnNewButton_1.setBounds(200, 450, 110, 69);
        contentPane.add(btnNewButton_1);

        JButton btnNewButton_2 = new JButton("删除车辆");
        btnNewButton_2.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Service.delete();
            }
        });
        btnNewButton_2.setBounds(330, 450, 110, 68);
        contentPane.add(btnNewButton_2);

        JButton btnNewButton_3 = new JButton("查询车辆");
        btnNewButton_3.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Service.query();
            }
        });
        btnNewButton_3.setBounds(480, 450, 110, 66);
        contentPane.add(btnNewButton_3);

        JButton btnNewButton_4 = new JButton("车辆统计");
        btnNewButton_4.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Service.statistic();
            }
        });
        btnNewButton_4.setBounds(620, 450, 110, 66);
        contentPane.add(btnNewButton_4);


        textArea.setFont(new Font("Monospaced", Font.PLAIN, 16));
        textArea.setBounds(30, 80, 730, 350);

        contentPane.add(textArea);


    }
}
